package reflect;

import reflect.annotations.AutoRunMethod;

import java.lang.reflect.Method;

public class Test3 {
    public static void main(String[] args) throws Exception {
        Class cls = Class.forName("reflect.Person");
        Object obj = cls.newInstance();
        Method[] methods = cls.getMethods();
        for (Method m : methods) {
            if (m.isAnnotationPresent(AutoRunMethod.class)) {
                System.out.println("调用" + m.getName() + "方法");
                m.invoke(obj);
            }
        }
    }
}